import 'package:aio/aio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:app/generated/app_strings.dart';
import 'package:app/src/http/bean/http_data.dart';
import 'package:app/src/http/bean/wroks/address_bean.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';
import 'package:app/src/ui/app_ui.dart';
import 'package:app/src/ui/route/helper/route_helper.dart';
import 'package:app/src/ui/route/works/public/items/ui_base.dart';
import 'package:app/src/ui/route/works/public/items/ui_card.dart';

import '../../../../../http/bean/works_2023/purorderInfo_bean.dart';
import '../../../../../http/bean/worksdo/material_requisition_bean.dart';
import '../../../../../http/bean/wroks/dispatchingaudit_bean.dart';
import '../../../../../http/model/config_model.dart';
import '../../../../dialog/dailog.dart';

///采购单信息
class UiPurorderAudit {
  ///data 信息
  ///oldData 历史信息
  static Widget build(BuildContext context, PurOrderInfoBean? data,
      PurOrderInfoBean? oldData, StateSetter setState,
      {String? title}) {
    if (data == null) {
      return AppUi.getEmptyView();
    }
    List<Widget> children = [];
    if (StringUtils.isEmpty(title)) {
      title = AppStrings.of(context).PurOrderInfo; //采购单信息
    }
    var isGrey=false;
    children.add(UiBase.title(context, title)); //标题
    children.add(UiBase.item(context, AppStrings.of(context).PurOrderCode,
        data?.PurOrderCode, oldData?.PurOrderCode,
        isAllowEmpty: true, isGrey: isGrey)); //采购单号
    children.add(UiBase.item(context, AppStrings.of(context).OrderType,
        data?.getOrderType(context), oldData?.getOrderType(context),
        isAllowEmpty: true, isBlue: false, isGrey: isGrey)); //采购类型
    children.add(UiBase.item(context, AppStrings.of(context).FactoryName3,
        data?.FactoryName, oldData?.FactoryName,
        isGrey: isGrey, isAllowEmpty: true)); //工厂
    if (!data!.isOrderType1()) {
      //非大额采购
      children.add(UiBase.item(context, AppStrings.of(context).SupplierName,
          data?.SupplierName, oldData?.SupplierName,
          isGrey: isGrey, isAllowEmpty: true, isStart: true)); //供应商
      children.add(UiBase.item(context, AppStrings.of(context).TaxCode,
          data?.TaxCode, oldData?.TaxCode,
          isGrey: isGrey, isAllowEmpty: true, isStart: true)); //税码
      children.add(UiBase.item(context, AppStrings.of(context).TaxRate2,
          data?.TaxRate, oldData?.TaxRate,
          unit: "%", isGrey: isGrey, isAllowEmpty: true)); //税率
      children.add(UiBase.item(context, AppStrings.of(context).CurrencyType2,
          data?.getCurrencyType(context), oldData?.getCurrencyType(context),
          isGrey: isGrey, isAllowEmpty: true)); //币种
      children.add(UiBase.item(
          context, AppStrings.of(context).Erate, data?.Rate, oldData?.Rate,
          isGrey: isGrey, isAllowEmpty: true)); //汇率
    }
    children.add(UiBase.item(
        context, AppStrings.of(context).Note, data?.BeiZhu, oldData?.BeiZhu,
        isGrey: isGrey, isAllowEmpty: true)); //备注
    var column = UiBase.column(context, children);
    var card = UiCard.build(context, column);
    return card;
  }
}
